package com.chaos.meta.common;

import com.chaos.meta.config.CustomSessionRegistry;
import org.springframework.security.core.session.SessionInformation;

/**
 * @author naicha
 */
public class SessionManager {
    public static CustomSessionRegistry sessionRegistry = null;

    public static void init(CustomSessionRegistry sessionRegistry) {
        SessionManager.sessionRegistry = sessionRegistry;
    }

    public static boolean expireNow(String sessionId) {
        if (null != SessionManager.sessionRegistry)
        {
            SessionInformation sessionInformation = SessionManager.sessionRegistry.getSessionInformation(sessionId);
            sessionInformation.expireNow();
            return true;
        }
        return false;
    }

    public static SessionInformation getSessionInformation(String sessionId) {
        return SessionManager.sessionRegistry.getSessionInformation(sessionId);
    }
}